<!-- 详情页 -->
@extends('home.index.layout')
@section('content')
<link href="{{url('ho/css/product_detail.css')}}" rel="stylesheet" type="text/css">


@section('fen')
<!-- 头部 -->
        <div class="header clearfix">
            <div class="wrap">
                <div class="logo" style="background:url(/uploads/{{$data->logo or 'logo.jpg'}})">
                    <a href="{{url('/')}}"></a>
                </div>
 <!--搜索 开始-->
                <div class="search" style="position:relative;">
                    <div class="search-bar clearfix">
                        <input id="keyword" name="keyword" class="search-input" value="输入商品名／编号／拼音" onfocus=" if (this.value == '输入商品名／编号／拼音') {this.value = '';this.style.color = '#000';} " onblur=" if (this.value == '') {this.value = '输入商品名／编号／拼音';this.style.color = '#999';} " style="color: rgb(153, 153, 153);" type="text">
                        <input class="search-btn" value="搜索" type="submit">
                    </div>
                    <ul class="hide" id="shelper" style="display: none;"></ul>
                    <div class="search-keywords" id="keywords">
                            <a href="#" target="_blank">大闸蟹</a>
                            <a href="#" class="hot" target="_blank">蓝莓</a>
                            <a href="#" target="_blank">阿克苏</a>
                            <a href="#" class="hot" target="_blank">易果俱乐部</a>
                            <a href="#" class="hot" target="_blank">奇异果</a>
                        </div>
                </div>
                <!--购物车 开始-->
<div class="shopping-cart">
    <dl>
        <dt class="shopping-btn"><a href="{{url('/cart/index')}}"> <span class="totleNum"><b>{{session('total_Number') ? session('total_Number') : '0'}}</b></span><b class="totlePrice">{{session('total_Money') ? session('total_Money') : '0.0'}}</b></a></dt>
        <dd class="shopping-list">
            <div class="spacer"></div>
            @if(session('goods_list'))
            <div class="goods" style="">
                <p id="deliveryType" style=""></p>
                <ul>
                        @foreach(session('goods_list') as $u)
                        <li><div class="l"><a href="{{url('/detail')/$u['gid']}}" target="_blank"><img src="{{url('/uploads/gPhoto')}}/{{$u['pic'] or 'default.jpg'}}" width="42" height="42"></a></div><div class="c"><a href="{{url('/detail')/$u['gid']}}">{{$u['gname']}}</a></div><div class="r"><b>¥{{$u['gprice']}}</b> * {{$u['count']}}<a href="javascript:;" onclick="">删除</a></div></li>
                            
                        @endforeach
                </ul>
                <div class="price-total">
                    <div><span class="totleNum">共<b>{{session('total_Number') ? session('total_Number') : '0'}}</b>件商品</span><span>共计<b class="totlePrice">{{session('total_Money') ? session('total_Money') : '0.0'}}</b></span></div>
                    <div><a href="{{url('/cart/index')}}" class="settleup">去购物车</a></div>
                </div>
            </div>
            @else
            <div class="nogoods" style="">
                购物车中还没有商品，赶紧选购吧！{{-- dd(session('goods_list')) --}}
            </div>
            @endif
        </dd>
    </dl>
</div>
                <!--购物车 结束-->
            </div>
        </div>

        






@endsection

<!-- 详情页主体部分 -->
<div class="wrap">
{{--dd($data)--}}
    <!--面包屑-->
    <div class="crumbs">
        <a class="ml0" href="/">首页</a>
        >
<a href='/products/01_channelhome.html'>进口水果</a>>                    <a href="/products/0109_pingguo.html">苹果</a>
>  {{$data->gname or ''}}
    </div>
    <!--产品详情-->
    <div class="content clearfix">
        <div class="product-intro clearfix j_product">
            <!--预览图-->
            <div class="pic-preview">
                <div class="pic-big">
                {{--dd($smallPic)--}}
                @foreach($smallPic as $pic)
                    <img class="j_product_img" width="500" height="500" src="{{url('/uploads/gPhoto/')}}/{{$pic->photo}}" style="display:  block;">
                    
                @endforeach    
                </div>
                <div class="pic-thumb">
                    <div class="picList">
                        <ul>
                            @foreach($smallPic as $pic)
                            <li><img width="85" height="85" src="{{url('/uploads/gPhoto/')}}/{{$pic->photo}}"></li>
                            @endforeach
                        </ul>
                    </div>
                </div>

            </div>
            <div class="product-info">
                <div class="summary-name">
                    <h1>{{$data->gname or ''}}</h1>
                    <p></p>
                    <input type="hidden" name="CommodityId" id="CommodityId" value="8b7d6554-c07f-4cca-a606-c970a35d337b" />
                </div>
                <div class="summary-price clearfix">
                    <div class="pro-price">
                        <div>
                            <span>价格：</span>
                            <span><em>¥</em><strong>{{$data->gprice or '0.00'}}</strong></span>
                        </div>
                    </div>
                    <div class="pro-review">
                        <p>总体满意度</p>
                        <p><b>{{$level_avg or '5.0'}}</b> 分</p>
                        <p><a href="#comment" id="pllabel"><span>(评论数{{$total}})</span></a></p>
                    </div>
                </div>
                <div class="summary-other clearfix">
                    <div class="left">



<div class="pro-promo clearfix" style="margin-bottom:0px;padding-bottom:0px;border-bottom:none;">
    <ul>
    </ul>
</div>
<div class="choose clearfix">
    <div class="dt">规格：</div>
    <div class="dd">
        <ul class="guige">
                <li class="selected">
                    <a href="" onclick="return false">
                        <span>￥{{$data->gprice or '0.00'}}</span>
                        <span>1kg/组</span>
                        <i></i>
                    </a>
                </li>


                <script type="text/javascript">
                    $('.guige > li').on('click',function(){
                        if($(this).attr('class')){
                            $(this).removeClass();
                        }else{
                            $(this).addClass('selected');
                        }
                    })
                </script>
        </ul>
    </div>
</div>
                                                    <div class="pro-service">满百包邮，<b>20:00</b> 前完成订单 预计明日<b>
                                                        <script type="text/javascript">
                                                            function GetDateStr(AddDayCount) {
                                                                var dd = new Date();
                                                                dd.setDate(dd.getDate()+AddDayCount);
                                                                var m = dd.getMonth()+1;//获取当前月份的日期
                                                                var d = dd.getDate();
                                                                return m+"月"+d+"日";
                                                            }
                                                            document.write(GetDateStr(1));
                                                            
                                                        </script>

                                                    </b>送达</div>
                        <div class="pro-amount clearfix">
                            <div class="dt">数量：</div>
                            <div class="dd">
                                <div class="spinner">
                                    <button class="decrease" disabled="disabled">-</button>
                                    <input type="text" class="spinner value" value=1 id="p_number" maxlength="2">
                                    <button class="increase">+</button>
                                </div>
                                <script type="text/javascript">
                                    $('.increase').on('click',function(){
                                        var num = 1 + parseInt($('#p_number').val());
                                        $('.decrease').removeAttr('disabled');
                                        $('#p_number').val(num)
                                    });
                                    $('.decrease').on('click',function(){
                                        if(parseInt($('#p_number').val())==1){
                                            $('.decrease').Attr('disabled','disabled');
                                        }
                                        var num = parseInt($('#p_number').val()) - 1;
                                        $('#p_number').val(num)
                                    });
                                    
                                    // alert(a)
                                </script>
                                    <div class="addcart"><a class="btn-gn" href="#" onclick="return false"><i></i>加入购物车</a></div>
                            </div>
                        </div>
                        <div class="pro-share clearfix">
                            <div class="favorite"><a href="javascript:;" onclick=""><i></i>收藏</a></div>
                        </div>
                        <script type="text/javascript">
                            $('.favorite > a').on('click',function(){

                                    $.ajax({
                                        async:true,
                                        url:"{{ asset('/user/addFavorite') }}",
                                        type:'GET',
                                        data:{gid:{{$data->gid}}},
                                        success:function(){
                                            alert('已加入收藏');

                                        },
                                        error:function(){

                                            alert('加入收藏失败，请重试');
                                        },
                                    });
                                
                            })
                        </script>


                    </div>
                    <div class="right">
                        <table width="100%" cellspacing="0" cellpadding="0" border="0" class="zx">
                            <tbody>
                                    <tr><th>原产地：</th><td>{{$data->home or ''}}</td></tr>
                                <tr><th>商品编号：</th><td>{{$data -> gid or ''}}</td></tr>
                                <tr><th>发货地：</th><td>北京</td></tr>
                                
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="content clearfix">
        <!--左侧-->
        
        <!--右侧-->
            <!--商品详情-->
            <div class="product-detail">
                <div class="detail-tab">
                    <ul class="detail-ul">
                        <li class="active"><a href="#details">商品详情</a></li>
                        <li><a href="#comment">用户评论<b>{{$total}}</b></a></li>
                    </ul>
                            <div class="addcart"><a href="#" >加入购物车</a></div>
                </div>
                <div class="detail-content">
                    <!--商品详情-->
                    <div class="detail-item details clearfix" id="details">



    <table class="detail-table">
        <tbody>
                
                <tr>
                    <th>商品状态</th>
                    <td>
冷藏
                    </td>
                </tr>
        </tbody>
    </table>

@foreach($detailPic as $pic)
    <p><img src="{{url('uploads/gPhoto')}}/{{$pic->photo}}" style="width:"/></p>
@endforeach
<p><br/></p>                        
                                            </div>
                    <!--用户评论-->
                    <div class="detail-item " id="comment" style="display:none;">
                        <div class="comment-info clearfix">
                            <div class="score">总体满意度<b>{{$level_avg or '5.0'}}<span>分</span></b>(共有<strong>{{$total}}</strong>人评论)</div>
                            <div class="percent">
                                <ul class="slip">
                                    <li><b>好评</b><span w="" style="width: 100%;"></span><i></i></li>
                                    <li><b>中评</b><span w="" style="width:0%;"></span><i></i></li>
                                    <li><b>差评</b><span w="" style="width:0%;"></span><i></i></li>
                                </ul>
                            </div>
                            <div class="comment-btn">
                                前5位评论用户可获得更高悠币奖励
                                <a href="{{url('/comment')}}/{{$data->gid}}" class="btn-gn" id="commentBtn">我要评论</a>
                                <p>只有购买过该商品的用户才能评论</p>
                                <script type="text/javascript"></script>
                            </div>
                        </div>
                        <div class="comment-list clearfix">
                            <div class="comment-tab-wrap clearfix">
                                <div class="comment-tab">
                                    <span class="on" _votetype="0">全部评论（<font id="vote_all">{{$total}}</font>）</span>
                                    <!-- <span _votetype="1">好评（<font id="vote_hp"></font>）</span>
                                    <span _votetype="2">中评（<font id="vote_zp"></font>）</span>
                                    <span _votetype="3">差评（<font id="vote_cp"></font>）</span> -->
                                </div>
                                <div class="extra">
                                    <span class="">
                                        <select id="commontsort">
                                            <option value="0">按默认</option>
                                            <option value="1">按时间</option>
                                        </select>
                                    </span>
                                    <span class="sort"><label><input type="checkbox" value="1" id="commenthascontent" checked="checked">有内容</label></span>
                                </div>
                            </div>

                            <div id="ProductCommentVote">
                                <!-- 评论开始 --><div _votetype="0">

<div class="comment-con" style="display:block;">
    <ul>
    @foreach($comment_content as $v)
        <li>
                    <div class="comment-item">
                        <div class="user">
                            <img src="{{url('/uploads/yhtx')}}/{{$v->pic ? $v->pic : 'default.jpg'}}" width="60" height="60">
                            <span class="name">{{$v->email}}</span>
                            <span class="level">易果生鲜普通用户</span>
                        </div>
                        <div class="content-comment">
                            <div class="heading">
                                <div class="stars">
                                    <div class="stars-bg"><span style="width:80%"></span></div>
                                    <div><b>{{$v->level}}</b>分</div>
                                </div>
                                <div class="txt"><span>商品质量：良好</span><span>配送服务：好</span><span>服务质量：好</span></div>
                               
                                 <div class="date">{{$v->time}}</div>
                                    <div class="comefrom">
                                        来自

                                        <strong class="green">易果网WEB</strong>
                                        <div class="dorpdown" style="display: none;"><i></i><img src=""><span>扫一扫下载APP</span></div>
                                    </div>
                            </div>
                            <div class="reply">
                                {{$v->content}}
                                <br>
                                <div class="reply-images">

                                </div>
                                <div class="reply-image-big"><img src="" width="500" height="500"></div>
                            </div>
                                <div class="yiguo-reply">
                                    <dl>
                                        <dt>[易果回复]</dt>
                                        <dd>{{$v->reply}}<br></dd>
                                    </dl>
                                </div>
                        </div>
                    </div>
                </li>
    @endforeach
    </ul>
       
        
</div>
</div><!-- 评论内容结束 -->
                                <div _votetype="1" style="display:none;"></div>
                                <div _votetype="2" style="display:none;"></div>
                                <div _votetype="3" style="display:none;"></div>
                                <div _votetype="4" style="display:none;"></div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script type="text/javascript" src="{{url('ho/js/product_detail.js')}}"></script>
<script type="text/javascript">
    // 加入购物车
    $('.addcart > a').on('click',function(){
        if( $('.guige > li').attr('class')){
            var count = $('#p_number').val();
            $.ajax({
                async:true,
                url:"{{ asset('/cart/ajax') }}",
                type:'GET',
                data:{gid:{{$data->gid}},count:count},
                success:function(data){
                    // alert(111)

                },
                error:function(){

                    alert('加入购物车失败了，请重试');
                },
                timeout:1000
            });
        }else{
            alert('请选择规格');
        }
    });
                
</script>

@endsection